package com.wanxi.education.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wanxi.education.mapper.OrderBackMapper;
import com.wanxi.education.model.vo.order.OrderFuzzyQueryVo;
import com.wanxi.education.model.vo.order.OrderGoBackVo;
import com.wanxi.education.model.vo.order.OrderUpdateVo;
import com.wanxi.education.service.OrderBackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: 寇文宝
 * @Description:
 * @Date: Created in 2021/9/24
 * @Version: 1.0
 */
@Service
public class OrderBackServiceImpl implements OrderBackService {
    @Autowired
    private OrderBackMapper orderBackMapper;

    /**
     * 订单管理查询订单分页+模糊查询
     *
     * @param orderFuzzyQueryVo 模糊查询vo类，分页参数，视频名称，视频uri，分页参数
     * @return 订单分页数据
     */
    @Override
    public PageInfo<OrderGoBackVo> findPage(OrderFuzzyQueryVo orderFuzzyQueryVo) {
        PageHelper.startPage(orderFuzzyQueryVo.getPageNum(), orderFuzzyQueryVo.getPageSize());
        List<OrderGoBackVo> orderGoBackVoList = orderBackMapper.findPage(orderFuzzyQueryVo);
        return new PageInfo<>(orderGoBackVoList);
    }

    /**
     * 管理员查看订单详情（订单号和订单状态）
     *
     * @param id 订单id
     * @return 订单号+订单状态
     */
    @Override
    public OrderUpdateVo findById(Long id) {
        OrderUpdateVo orderUpdateVo = orderBackMapper.findById(id);
        return orderUpdateVo;
    }

    /**
     * 管理员修改订单状态
     *
     * @param orderUpdateVo 订单id，订单状态，订单号
     */
    @Override
    public int update(OrderUpdateVo orderUpdateVo) {
        return orderBackMapper.update(orderUpdateVo);
    }
}
